AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')

function ENT:Initialize()
	self:SetModel("models/props_combine/suit_charger001.mdl")
	self.Entity:SetMoveType( MOVETYPE_NONE )
	self.Entity:SetSolid( SOLID_VPHYSICS )
	self.Entity:SetUseType( SIMPLE_USE )
end

function ENT:SpawnFunction(ply) 
	self:SetNWEntity("owning_ent", ply)
	self.Owner = ply
	self:SetNWString("Owner", "Shared")
	self.Spawned = true
	self:Spawn()
	self.Bank = false
end

function ENT:Use( activator, caller )

	if ( !caller:IsPlayer() ) then return end
	if !self.Bank and self.Owner != caller then
		Notify(caller, 1, 4, "The bank machine is off.")
		return false
	end
	umsg.Start("bankmachinemenu", caller)
		umsg.Long(caller:GetMoneyOfBank())
		umsg.Bool(caller == self.Owner)
		if caller == self.Owner then
			umsg.Long(self.SavedMoney)
		else
			umsg.Long(0)
		end
	umsg.End()
	
end

function ENT:Think()
	if not self.Spawned then
		return
	end
	if self.Owner == nil then
		self:Remove()
		return
	end
	if self.Owner:Team() != TEAM_banker and CfgVars["removeclassitems"] >= 1 then
		self:Remove()
		return
	end
end